package cn.bonoon.kernel.web.html;

import cn.bonoon.kernel.IdGenerator;


/**
 * <pre>
 * 界面代码生成器的基本父类，定义了
 * 1.ServletContext
 * 2.id
 * 3.html
 * 4.includes
 * 5.javascript
 * 6.javascript in jquery
 * </pre>
 * <pre>
 * 定义基本的生成界面的基类，直接子类包括：
 * {@link cn.bonoon.kernel.web.html.AbstractUIBuilder AbstractUIBuilder}
 * {@link cn.bonoon.kernel.web.html.grid.DatagridBuilder LayoutGridBuilder}
 * {@link cn.bonoon.kernel.web.html.grid.DatagridBuilder LayoutGridBuilder}
 * </pre>
 * @author jackson
 *
 */
public abstract class AbstractHtmlBuilder {
	
//	protected final static char E = '\'';
	/**
	 * 每一个界面生成器都需要有一个唯一的或继承于父界面的ID
	 */
	protected final String id;
	
	protected final InternalHtmlInfo html;
	
	protected AbstractHtmlBuilder(/*String id, */InternalHtmlInfo html){
		//this.id = id;
		this.id = IdGenerator.fixed();
		this.html = html;
	}
	
	public String path(String url){
		return html.path(url);
	}
	
	public String getId() {
		return id;
	}
	
	public StringBuilder getScript() {
		return html.getScript();
	}
	
	public StringBuilder getIncludes() {
		return html.getIncludes();
	}

	public StringBuilder getHtml() {
		return html.getHtml();
	}

	public StringBuilder getBlock() {
		return html.getBlock();
	}

	@Override
	public String toString() {
		return html.getHtml().toString();
	}
	/**
	 * <pre>
	 * 在调用解析方法之前需要
	 * 在调本函数之前，应该调用相应的初始化函数
	 * </pre>
	 * @return
	 * @throws Exception
	 */
	public abstract boolean parse() throws Exception;
}
